package com.itheima.map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class Demo03 {

    public static void main(String[] args) {
        Map<String ,Integer> map= new HashMap<>();
        map.put("坤坤",26);
        map.put("签签",32);
        map.put("滔滔",28);
        map.put("小鹿",30);

        //entrySet 可以获取到所有的  键值对   集合
        //Map.Entry<String ,Integer> entry= Map.entry("坤坤",26);
        Set<Map.Entry<String ,Integer>> entries = map.entrySet();
       /* Iterator<Map.Entry<String, Integer>> iterator = entries.iterator();
        while (iterator.hasNext()){
            Map.Entry<String, Integer> entry = iterator.next();
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+"今年"+value);
        }*/
        /*for (Map.Entry<String, Integer> entry : entries) {
            String key = entry.getKey();
            Integer value = entry.getValue();
            System.out.println(key+"今年"+value);
        }*/
        entries.forEach(entry-> System.out.println(entry.getKey()+"今年"+entry.getValue()));
    }
}
